import { Body, Controller, Get, Post } from "@nestjs/common";
import { ApiBody, ApiResponse, ApiTags } from "@nestjs/swagger";
import { Photo } from "src/model/photo.entity";
import { Result } from "src/model/result";
import { PhotoService } from "src/service/photo.service";

@ApiTags("photos")
@Controller("photos")
export class PhotoController{
    constructor(private readonly photoService:PhotoService) { 
    }
    @Post("/save")
    @ApiResponse({ status: 201, description: 'The record has been successfully created.'})
    @ApiBody({ type: Photo })
    async saveUser(@Body() photo:Photo): Promise<Result<any>> { 
        return await this.photoService.save(photo);
    }

    @Get("/list")
    async list(): Promise<Result<any>>{ 
        return await this.photoService.findAll()
    }
}